<?php  
// File -> app/controllers/components/schedule_functions.php

/**  
 * ScheduleFunctions Component 
 *  
 * @author Marcin Rabczyński
 * @version 1.0 
 * @license MIT 
 * @category Components 
 */ 

class ScheduleFunctionsComponent extends Object {
	/**
	 * Reference to controller
	 *
	 * @var Object
	 * @access Private
	 */
	var $__controller = null;
	
	/**
	* Initializes this component
	*
	* @param Object $controller - reference to controller
	* @access Public
	*/
	function initialize(&$controller) {
		$this->__controller = &$controller;
		$this->Course = ClassRegistry::init('Course');
		$this->Mode = ClassRegistry::init('Mode');
	}
	
	/**
	* Changing string with polish letters to string with non polish letters
	*
	* @param String $strTextPL - Text with polish letters
	* @access Public
	* @return String - Text without polish letters
	*/
	function removePL($strTextPL)
	{
		$strText = strtr($strTextPL, 'ĘÓĄŚŁŻŹĆŃęóąśłżźćń', 'EOASLZZCNeoaslzzcn');
		return $strText;
	}
	function modeName_to_id($strName)
	{
		$arrRecord = $this->Mode->find('first', array('conditions' => array('mode_name' => $strName)));
		//debug($arrRecord['Mode']);
		return $arrRecord['Mode']['id'];
	}
	function id_to_modeName($intId)
	{
		$arrRecord = $this->Mode->find('first', array('conditions' => array('id' => $intId)));
		return $arrRecord['Mode']['mode_name'];
	}
	function courseName_to_id($strName)
	{
		$arrRecord = $this->Course->find('first', array('conditions' => array('course_name' => $strName)));
		//debug($arrRecord['Course']);
		return $arrRecord['Course']['id'];
	}
	function id_to_CourseName($intId)
	{
		$arrRecord = $this->Course->find('first', array('conditions' => array('id' => $intId)));
		return $arrRecord['Course']['course_name'];
	}
}